{% extends "shm/base.html" %}
{% block extrastyle %}<link rel="stylesheet" type="text/css" href="{% load media %}{% media_prefix %}css/">{% endblock %}
{% block department_tree %}

<script type="text/javascript" src="{% media_prefix %}js/phones.js"></script>
<script type="text/javascript" src="{% media_prefix %}js/jquery.form.min.js"></script>
<script type="text/javascript" src="{% media_prefix %}js/tree.js"></script>



<link rel="stylesheet" type="text/css" href="{% load media %}{% media_prefix %}css/phones.css">
<link rel="stylesheet" type="text/css" href="{% load media %}{% media_prefix %}css/sklad-tree.css">


<script type="text/javascript">
$(document).ready(function(){
  UnHideOpenNodes();

  {% for item in category_path %}
    UnHideNodeItem('tn_'+{{item.id}});
  {% endfor %} 

  var selectitem = document.getElementById('ti_{{ currentdepartment }}');
  if(selectitem) 
    selectitem.style.fontWeight = 'bold'; 
})    
    
    
function get_dept(id){
  $('#department_detail').load('/shm/department/detail/'+id+'/');
  return false;
}
</script>

    <h3>Отделы</h3> 
    <p><a href="">Добавить отдел</a></p>
    <div class="treeview">
 
        <ul>   
            <li>
                <div><p><a href="#" class="sc" onclick="return UnHide(this)"><img src="{% media_prefix %}img/minus.gif"/></a>
                <a href="#">Категории</a></p></div>
                <ul>
                    {% load tree %}
                    {% tree department_tree|astree:"parent" %}
                        <a href="" id="ti_{{item.id}}"  OnClick="return get_dept({{ item.id }})">
                        <img src="{% if item.picture %}{% media_prefix %}{{ item.picture }}{% else %}{% media_prefix %}img/department.gif{% endif %}" class="i" />{{ item.name }}</a>
                    {% endtree %}
                </ul>
            </li>
        </ul>

   </div>
 

  
{% endblock %}
